/******************************************************************************
 * Copyright (C) 2017 Chengdu Dlhd information industry co. LTD.
 * All Rights Reserved.
 * 本软件为成都顶联互动信息产业有限公司开发研制。未经本公司正式书面同意，其他任何个人、团体不得使用、复制、修改或发布本软件.
 *****************************************************************************/
package net.dgg.dggcloud.service.jrcrm.utils;


import net.dgg.dggcloud.service.jrcrm.constant.BusinessConstant;
import net.dgg.dggcloud.service.jrcrm.constant.CustomerRecordConstant;

/**
 * @ClassName 〈BusinessStatusUtil>
 * @Description
 * @Author 朱永波
 * @Date 2017/12/12 11:14
 */
public class BusinessStatusUtil {

    /**
     * 翻译商机的显示状态
     * @param status 实际状态
     * @param location 所在库
     * @param oprate 最后一次操作
     * @return
     */
    public static String translateShowStatus(String status,String location,String oprate){
        try {
            String businessShowStatus = "未知";
            int businessLocation = Integer.valueOf(location);
            if (businessLocation == BusinessConstant.BUS_STORE_SOURCE) {
                businessShowStatus = status;
                if(CustomerRecordConstant.BUS_OPERATE_ZYD_SHUIHUI.equals(oprate)){
                    businessShowStatus="拾回待分配";
                }
            } else if ( businessLocation ==  BusinessConstant.BUS_STORE_EMP) {
                if (CustomerRecordConstant.BUS_OPERATE_HIDE_REJECT.equals(oprate)) {
                    businessShowStatus = "隐藏驳回待跟进";
                }else if (CustomerRecordConstant.BUS_OPERATE_INVALID_REJECT.equals(oprate)) {
                    businessShowStatus = "返无效驳回待跟进";
                }else if (CustomerRecordConstant.BUS_OPERATE_DELETE_REJECT.equals(oprate) ) {
                    businessShowStatus = "剔除驳回待跟进";
                }else if (CustomerRecordConstant.BUS_OPERATE_MOVE_EMP.equals(oprate) || CustomerRecordConstant.BUS_OPERATE_NOCALL_EMP.equals(oprate) ) {
                    businessShowStatus = "移交待跟进";
                }else{
                    businessShowStatus = status;
                }
            } else if (businessLocation == BusinessConstant.BUS_STORE_DEPARTMENT ||  businessLocation ==  BusinessConstant.BUS_STORE_INVALID) {
                businessShowStatus = String.valueOf(businessLocation);
            } else if (businessLocation == BusinessConstant.BUS_STORE_ORG) {
                businessShowStatus = "待审核";
                if (CustomerRecordConstant.BUS_OPERATE_HIDE.equals(oprate)) {
                    businessShowStatus = "隐藏待审核";
                }else if (CustomerRecordConstant.BUS_OPERATE_INVALID.equals(oprate)) {
                    businessShowStatus = "返无效待审核";
                }else if (CustomerRecordConstant.BUS_OPERATE_DEPT.equals(oprate)&&status.equals(BusinessConstant.BUS_STATUS_DEPT_SING)) {
                    businessShowStatus = "部门待抢单";
                }
                else if (CustomerRecordConstant.BUS_OPERATE_DEPT.equals(oprate)&&status.equals(BusinessConstant.BUS_STATUS_DEPT)) {
                    businessShowStatus = "部门待分配";
                }
                else if (CustomerRecordConstant.BUS_OPERATE_DELETE.equals(oprate)) {
                    businessShowStatus = "剔除待审核";
                }else if(CustomerRecordConstant.BUS_OPERATE_LZ_WAIT_DO.equals(oprate)){
                    businessShowStatus = "流转待处理";
                }
            }else if(businessLocation == BusinessConstant.BUS_STORE_REFERRAl){
                //转介绍库
                businessShowStatus = "转介绍质检待审核";
                if(CustomerRecordConstant.BUS_OPERATE_REFERRAL_RETURN.equals(oprate)){
                    businessShowStatus = "转介绍已退回";
                }
            }else if(businessLocation == BusinessConstant.BUS_STORE_EP){
                businessShowStatus = "电销库";
                if(status.equals(BusinessConstant.BUS_STATUS_DOOR_FOLLOWING)){
                    businessShowStatus = "上门跟进中";
                }

            }else if(businessLocation == BusinessConstant.BUS_STORE_GH){
                businessShowStatus = "公海库";
            }else if(businessLocation == BusinessConstant.BUS_STORE_FQ){
                businessShowStatus = "废弃库";
            }
            return TranslateMapUtil.translateCode(businessShowStatus);
        }catch (Exception e){
            return "未知";
        }
    }
}
